import { NavBar } from 'antd-mobile';
import React, { useEffect, useState } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import dayjs from 'dayjs'
import axios from '../../api/index';
import styles from './css.module.css'
function index() {
  const [isSpeed,setIsSpeed]=useState(false)
  const [date,setDate]=useState(dayjs('2025-05-13').format('YYYY-MM-DD'))
  const {state}=useLocation()
  const {start,end}=state
  const nav=useNavigate()
  const getdata=async()=>{
    const res= await axios.post('/trip/train',{start,end,date,isSpeed})
    console.log(res);
  }
  useEffect(()=>{
    getdata()
  },[]) 
  return (
    <div>
      <NavBar onBack={()=>nav(-1)}>{start}-{end}</NavBar>
      <div className={styles.data}>
        <button onClick={()=>setDate(dayjs(date).subtract(1,'day').format('YYYY-MM-DD'))}>上一天</button>
        <div>{date}</div>
        <button onClick={()=>setDate(dayjs(date).add(1,'day').format('YYYY-MM-DD'))}>后一天</button>
      </div>
      <div className={styles.kkk} onClick={()=>nav('/detail')}> 
          <div>{start}-{end}</div>
          <div>是否高铁:是</div>
           <div>是否有票：否</div>
            <div>
              <div>一等座</div>
              <div>二等座</div>
              <div>商务座</div>
            </div> 
      </div>
       <div className={styles.kkk}> 
          <div>{start}-{end}</div>
          <div>是否高铁:是</div>
           <div>是否有票:是</div>
            <div>
              <div>一等座</div>
              <div>二等座</div>
              <div>商务座</div>
            </div> 
      </div>
       <div className={styles.kkk}> 
          <div>{start}-{end}</div>
          <div>是否高铁：否</div>
           <div>是否有票：否</div>
            <div>
              <div>一等座</div>
              <div>二等座</div>
              <div>商务座</div>
            </div> 
      </div>
       <div className={styles.kkk}> 
          <div>{start}-{end}</div>
          <div>是否高铁:是</div>
           <div>是否有票:是</div>
            <div>
              <div>一等座</div>
              <div>二等座</div>
              <div>商务座</div>
            </div> 
      </div>
       <div className={styles.kkk}> 
          <div>{start}-{end}</div>
          <div>是否高铁：否</div>
           <div>是否有票:是</div>
            <div>
              <div>一等座</div>
              <div>二等座</div>
              <div>商务座</div>
            </div> 
      </div>
       <div className={styles.kkk}> 
          <div>{start}-{end}</div>
          <div>是否高铁:是</div>
           <div>是否有票:是</div>
            <div>
              <div>一等座</div>
              <div>二等座</div>
              <div>商务座</div>
            </div> 
      </div>
       <div className={styles.kkk}> 
          <div>{start}-{end}</div>
          <div>是否高铁:是</div>
           <div>是否有票:是</div>
            <div>
              <div>一等座</div>
              <div>二等座</div>
              <div>商务座</div>
            </div> 
      </div>
    </div>
  )
}

export default index